package si.yun.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import si.yun.entity.PerCount;
import si.yun.entity.SyBeforeUser;
import si.yun.entity.SyClosure;
import si.yun.service.PersonnelService;

import java.util.*;


/**
 * @program: SiYunClass
 * @description: 人事功能web层
 * @author: 崔晓晨
 * @create: 2021-07-28 20:47
 **/
@RestController
@RequestMapping("/personnel")
public class PersonnelWeb {
    @Autowired
    private PersonnelService personnelService;
    /**
     * @Description  获取用户数据展示
     * @return si.yun.entity.PerCount
     * @Date 2021/7/29 14:37
     **/
    @RequestMapping("/selUserNum")
    public PerCount selUserNum(){
        PerCount perCount = personnelService.selUserNum();
        return perCount;
    }
    /**
     * @Description 获取期间内申请人员统计信息
     * @return si.yun.entity.SyApplyRecord
     * @Date 2021/7/28 21:03
     **/
    @RequestMapping("/selPerTab")
    public List<PerCount> selPerTab(int durDate){
        PerCount selPerTab = personnelService.selPerTab(durDate);
        List<PerCount> list = new ArrayList<>();
        list.add(selPerTab);
        return list;
    }
    /**
     * @Description  申请人统计
     * @return java.util.Map<java.lang.String,java.lang.Object> 
     * @Date 2021/7/29 13:28
     **/
    @RequestMapping("/selEcharts")
    public Map<String,Object> selEcharts(int durDate){
        PerCount selPerTab = personnelService.selPerTab(durDate);
        Map<String,Object> map = new HashMap<>();
        map.put("applyNum",selPerTab.getApplyNum());
        map.put("applyPass",selPerTab.getApplyPass());
        map.put("applyRejection",selPerTab.getApplyRejection());
        return map;
    }
    /**
     * @Description  获取用户统计
     * @return java.util.List<java.lang.Integer> 
     * @Date 2021/7/29 13:32
     **/
    @RequestMapping("/selUserEcharts")
    public List<Integer> selUserEcharts(){
        List<Integer> integers = personnelService.selUserEcharts();
        return integers;
    }
    /**
     * @Description  获取用户列表
     * @return si.yun.entity.JsonData 
     * @Date 2021/7/29 19:22
     **/
    @RequestMapping("/selUserTable")
    public List<SyBeforeUser> selUserTable(SyBeforeUser beforeUser){
        List<SyBeforeUser> beforeUsers = personnelService.selUserTable(beforeUser);
        return beforeUsers;
    }
    /**
     * @Description  添加停用的用户
     * @return boolean
     * @Date 2021/8/1 18:36
     **/
    @RequestMapping("addClosure")
    public boolean addClosure(SyClosure closure){
        int add = personnelService.addClosure(closure);
        if(add!=0){
            return true;
        }else{
            return false;
        }
    }
    /**
     * @Description  查询单个用户的详细信息
     * @return si.yun.entity.SyBeforeUser 
     * @Date 2021/8/1 18:58
     **/
    @RequestMapping("/selUserInfo")
    public SyBeforeUser selUserInfo(int userId){
        SyBeforeUser beforeUser = personnelService.selUserInfo(userId);
        return beforeUser;
    }
    /**
     * @Description  编译用户信息 ( 不能编译用户的学习时长  和 交易金额 以及 账号创建时间)
     * @return boolean 
     * @Date 2021/8/1 20:48
     **/
    @RequestMapping("/updSelUser")
    public boolean updSelUser(SyBeforeUser beforeUser){
        int upd = personnelService.updSelUser(beforeUser);
        if(upd!=0){
            return true;
        }else{
            return false;
        }
    }
    /**
     * @Description  查询封号用户列表
     * @return si.yun.entity.SyClosure 
     * @Date 2021/8/2 9:42
     **/
    @RequestMapping("/selClosureUserTable")
    public List<SyClosure> selClosureUserTable(SyClosure closure){
        List<SyClosure> closures = personnelService.selClosureUserTable(closure);
        return closures;
    }
    /**
     * @Description  解封用户 改变封号列表信息
     * @return boolean
     * @Date 2021/8/2 15:11
     **/
    @RequestMapping("/updClosure")
    public boolean updClosure(SyClosure closure){
        int upd = personnelService.updClosure(closure);
        if(upd!=0){
            return true;
        }else{
            return false;
        }
    }
    /**
     * @Description  删除停用后的封停日志
     * @return boolean
     * @Date 2021/7/30 15:38
     **/
    @RequestMapping("/delBeforeStatus")
    public boolean delBeforeStatus(int id){
        int del = personnelService.delBeforeStatus(id);
        if(del!=0){
            return true;
        }else{
            return false;
        }
    }
}
